package dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import vo.Base;
import dao.BaseDao;
@Repository
public class BaseDaoImpl implements BaseDao {
	@PersistenceContext(name="un")
	private EntityManager em;
	@Override
	public String addBase(Base b) {
		em.persist(b);
		return b.getId();
	}

	@Override
	public int deleteBase(String id) {
		Base base=em.getReference(Base.class, id);
		em.remove(base);
		return 1;
	}

	@Override
	public List<Base> findAllBases() {
		String jpql="from Base";
		List<Base> bs=em.createQuery(jpql).getResultList();
		return bs;
	}

}
